package com.yanqu.road.server.cmd.activity.langyabang;

import com.yanqu.road.message.YanQuMessage;
import com.yanqu.road.pb.activity.LangYaBangProto;
import com.yanqu.road.server.cmd.CrossUnionCommand;
import com.yanqu.road.server.command.Cmd;
import com.yanqu.road.server.logic.MessageHelper;
import com.yanqu.road.server.manager.activity.langyabang.CrossLangYaBangMgr;
import com.yanqu.road.server.protocol.ClientProtocol;
import com.yanqu.road.server.protocol.CrossProtocol;
import com.yanqu.road.server.protocol.GameProtocol;
import com.yanqu.road.utils.YanQuMessageUtils;

@Cmd(code = CrossProtocol.C_LANG_YA_BANG_CHOOSE_DECLARE_WAR_BATTLE_USER,desc = "宣战选择用户开始pvp")
public class CrossLangYaBangChooseDeclareWarBattleUserCmd extends CrossUnionCommand {

    private int activityId;

    private int declareUid;

    private long enemyUserId;

    @Override
    public boolean parseData(YanQuMessage packet) throws Exception {
        LangYaBangProto.ChooseDeclareWarBattleUserReq req = LangYaBangProto.ChooseDeclareWarBattleUserReq.parseFrom(packet.getBytes());
        activityId = req.getActivityId();
        declareUid = req.getDeclareUid();
        enemyUserId = req.getUserId();
        return true;
    }

    @Override
    public void execute(YanQuMessage packet) throws Exception {
        LangYaBangProto.ChooseDeclareWarBattleUserResp.Builder builder = CrossLangYaBangMgr.chooseDeclareWarBattleUser(activityId, groupId, packet.getPlayerId(), declareUid, enemyUserId);
        YanQuMessage pbMsg = YanQuMessageUtils.buildMessage(ClientProtocol.U_LANG_YA_DECLARE_WAR_CHOOSE_USER,builder);
        MessageHelper.sendPacket(serverId,packet.getPlayerId(),pbMsg);
    }

    @Override
    public void sendData() {

    }
}
